﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class FlashSelf : MonoBehaviour {

	Image m = null;
	float currentPer = 0f;
	public void setProportion(float per, bool immediate = false)
	{
		currentPer = per;

		if (immediate) {
			m.fillAmount = per;
		}
	}

	void Awake()
	{
		m = GetComponent<Image> ();
	}

	// Use this for initialization
	void Start () {
		
	}
	
	// Update is called once per frame
	void Update () {
		Color c = m.color;
		c.a = Mathf.PingPong (Time.time, 1f);
		m.color = c;

		m.fillAmount = Mathf.Lerp(m.fillAmount, currentPer, Time.deltaTime*2f);
	}
}
